package com.ruoyi.project.module.api.controller;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.module.api.domain.ReportVo;
import com.ruoyi.project.module.report.domain.Report;
import com.ruoyi.project.module.report.service.IReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/report")
@Api("前台报告接口")
public class AppReportController extends BaseController {

    @Autowired
    private IReportService reportService;

    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("报告查询列表")
    public TableDataInfo list(Report report) {
        startPage();
        List<Report> list = reportService.selectReportList(report);
        List<ReportVo> result = new ArrayList<>();
        for(Report r:list){
            ReportVo reportVo = new ReportVo();
            BeanUtil.copyProperties(r,reportVo);
            result.add(reportVo);
        }
        return getDataTable(result);
    }

}
